<?php


namespace seecms\lib\builder\modal;

use seecms\SeeLang;

class Confirm
{
    /**
     * @var string
     */
    protected $icon = 3;

    /**
     * @var string
     */
    protected $title = '';

    /**
     * @var string
     */
    protected $content = '';

    /**
     * @param string $title
     * @param string $content
     * @return Confirm
     */
    public static function init(string $title = '', string $content = ''): Confirm
    {
        $self = new static();
        $self->title = $title;
        $self->content = $content;
        return $self;
    }

    /**
     * @return int|string
     */
    public function getIcon()
    {
        return $this->icon;
    }

    /**
     * @param $icon
     * @return $this
     */
    public function setIcon($icon): Confirm
    {
        $this->icon = $icon;

        return $this;
    }

    public function getTitle(): string
    {
        return $this->title ?: SeeLang::dialog('miss_tips');
    }

    /**
     * @param string $title
     * @return $this
     */
    public function setTitle(string $title): Confirm
    {
        $this->title = $title;

        return $this;
    }

    public function getContent(): string
    {
        return $this->content ?: SeeLang::dialog('miss_content');
    }

    /**
     * @param string $content
     * @return $this
     */
    public function setContent(string $content): Confirm
    {
        $this->content = $content;

        return $this;
    }

    public function toArray(): array
    {
        return [
            'icon' => $this->getIcon(),
            'title' => $this->getTitle(),
            'content' => $this->getContent(),
        ];
    }
}